﻿<%@ Page Language="c#" CodeBehind="ClientListView.aspx.cs" AutoEventWireup="false" Inherits="UDS.SubModule.CM.ClientListViewPage" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
  <title>客户列表</title>
  <uds:Style runat="server" Href="~/css/BasicLayout.css" />
  <script type="text/javascript">
  //<!--
  function fnSelectAll(state) {
    var inputs = document.body.getElementsByTagName("INPUT");
    for (var i = 0; i < inputs.length; i++) {
      var input = inputs[i];
      if (input.type === "checkbox") {
        input.checked = state;
      }
    }
  }

  function fnAddClient() {
    window.open("Client.aspx", "_blank");
  }

  function fnAddLinkMan() {
    var clientId = getLastSelectedClientID();
    if (clientId == null || isNaN(clientId)) {
      alert("No selected client id.");
    }
    else {
      window.open("LinkMan.aspx?ClientID=" + clientId + "&form=ClientList", "_blank");
    }
  }

  function fnAddContact() {
    var clientId = getLastSelectedClientID();
    if (clientId == null || isNaN(clientId)) {
      alert("No selected client id.");
    }
    else {
      window.open("ClientContact_thisWeek.aspx?ClientID=" + clientId, "_blank");
    }
  }

  function getLastSelectedClientID() {
    var table = document.getElementById("<%= dgd_Client.ClientID %>");
    var lastId = null;
    if (table != null) {
      var inputs = table.getElementsByTagName("INPUT");
      for (var i = 0; i < inputs.length; i++) {
        var input = inputs[i];
        if (input.type === "checkbox") {
          lastId = parseInt(input.getAttribute(""), 10);
        }
      }
    }
    return lastId;
  }
  //-->
  </script>
</head>
<body>
  <form id="ClientListView" method="post" runat="server">
    <uds:PageTitle runat="server" HintImage="~/DataImages/ClientManage.gif">
      <TitlePanel>我的客户 &#187; 查看视角
        <asp:DropDownList ID="ddl_MySubordinate" runat="server" AutoPostBack="True" CssClass="shortInput" />
      </TitlePanel>
      <RightPanel>
        <asp:Panel ID="pnl" runat="server" Height="8px" Width="499px" Visible="true">
          <input class="redbuttoncss optionbutton" onclick="window.open('Stat/Contact_Client.aspx','_blank')" type="button" value="汇总" />
          <input class="redbuttoncss optionbutton" onclick="window.open('Search/ClientInfo.aspx','_blank')" type="button" value="查询" />
          <input class="redbuttoncss optionbutton" onclick="fnSelectAll(true)" type="button" value="全选" />
          <asp:Button ID="btn_Del" runat="server" CssClass="redbuttoncss optionbutton" Text="删除" />
          <input type="button" onclick="fnAddClient()" value="添加客户" class="redbuttoncss optionbutton" />
          <input runat="server" id="btn_AddLinkman" type="button" onclick="fnAddLinkMan()" value="添加联络人" class="redbuttoncss optionbutton" />
          <input runat="server" id="btn_AddContact" type="button" onclick="fnAddContact()" value="添加接触" class="redbuttoncss optionbutton" />
        </asp:Panel>
      </RightPanel>
    </uds:PageTitle>
    <table class="gbtext" id="Table1" cellspacing="0" cellpadding="0" width="100%" border="0">
      <tr>
        <td>
          <table class="gbtext" id="Table3" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tr>
              <td id="TD1" valign="middle" align="center" width="90" background="../../images/maillistbutton2.gif" runat="server">&nbsp;<asp:LinkButton ID="lbtn_MyClient" runat="server" CssClass="Newbutton">我的客户</asp:LinkButton><a href="ClientListView.aspx"></a></td>
              <td id="TD2" valign="middle" align="center" width="90" background="../../images/maillistbutton1.gif" runat="server">&nbsp;<asp:LinkButton ID="lbtn_coClient" runat="server" CssClass="Newbutton">我的协同客户</asp:LinkButton></td>
              <td style="height: 25px" align="right">&nbsp;</td>
              <td style="height: 25px" align="right">
                <asp:Panel ID="pnl_ClientInfo" runat="server">
                  &nbsp;共
                  <asp:Literal ID="ltl_ClientCount" runat="server" />位客户, 一个月内共接触
                  <asp:Literal ID="ltl_ContactTimes" runat="server" />次
                </asp:Panel>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <asp:DataGrid ID="dgd_Client" runat="server" Width="100%" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" BorderColor="#93BEE2" BorderWidth="1px" CellPadding="3" PageSize="15" DataKeyField="ID">
            <AlternatingItemStyle BackColor="#E8F4FF"></AlternatingItemStyle>
            <ItemStyle Font-Size="X-Small"></ItemStyle>
            <HeaderStyle ForeColor="White" BackColor="#337FB2"></HeaderStyle>
            <Columns>
              <asp:TemplateColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
                <ItemStyle HorizontalAlign="Right"></ItemStyle>
                <ItemTemplate>
                  <asp:CheckBox runat="server" ID="cbx1" ClientValue='<%# DataBinder.Eval(Container, "DataItem.ID") %>' />
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:BoundColumn Visible="False" DataField="ID" SortExpression="ID" HeaderText="编号" />
              <asp:TemplateColumn SortExpression="Name" HeaderText="客户名称">
                <ItemTemplate>
                  <asp:HyperLink ID="hlk_ClientName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>' NavigateUrl='<%# GetClientNameUrl(DataBinder.Eval(Container,"DataItem.ID").ToString())%>' Target="_blank" />
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:BoundColumn DataField="Linkman" SortExpression="Linkman" HeaderText="联系人">
                <ItemStyle Font-Size="X-Small"></ItemStyle>
              </asp:BoundColumn>
              <asp:TemplateColumn HeaderText="电话">
                <HeaderStyle Font-Size="X-Small"></HeaderStyle>
                <ItemStyle Font-Size="X-Small"></ItemStyle>
                <ItemTemplate>
                  <asp:Label runat="server" Text='<%# GetLinkmanTel(((DataRowView)Container.DataItem).Row.GetChildRows("ClientLinkmanID_Linkman")) %>' />
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:BoundColumn DataField="updatetime1" SortExpression="updatetime1" HeaderText="更新时间" />
              <asp:TemplateColumn HeaderText="目前状态">
                <HeaderStyle Font-Size="X-Small"></HeaderStyle>
                <ItemStyle Font-Size="X-Small"></ItemStyle>
                <ItemTemplate>
                  <asp:HyperLink runat="server" Text='<%# GetCurStatus(DataBinder.Eval(Container,"DataItem.Curstatus").ToString()) %>' Target="_blank" NavigateUrl='<%# GetContactUrl(DataBinder.Eval(Container,"DataItem.ID").ToString())%>' />
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn SortExpression="AddManID" HeaderText="添加人">
                <HeaderStyle HorizontalAlign="Right"></HeaderStyle>
                <ItemStyle Font-Size="X-Small" HorizontalAlign="Right"></ItemStyle>
                <ItemTemplate>
                  <asp:Label runat="server" Text='<%# GetAddMan(((DataRowView)Container.DataItem).Row.GetChildRows("ClientAddMan_Staff")) %>' />
                </ItemTemplate>
              </asp:TemplateColumn>
            </Columns>
            <PagerStyle NextPageText="上一页" PrevPageText="下一页" HorizontalAlign="Right" BackColor="#E8F4FF" Mode="NumericPages" />
          </asp:DataGrid>
        </td>
      </tr>
    </table>
  </form>
</body>
</html>
